package com.zysc.processflow.common.util;

import com.alibaba.fastjson2.JSON;
import org.slf4j.LoggerFactory;

import java.util.Map;

public class TokenUtils {

    // 日志
    private static org.slf4j.Logger logger = LoggerFactory.getLogger(TokenUtils.class);
    public static String getToken(String loginUrl) {
        String token="";
        String loginJsonStr = HttpUtils.getByClient(loginUrl);
        if (loginJsonStr.equals(1)) {
            logger.info("未能获取到token，请检查请求地址"+loginUrl+"或者网络连接是否正常。");
            return null;
        }else{
            Map loginmapdata = JSON.parseObject(loginJsonStr);
            token=JSON.parseObject(loginmapdata.get("data").toString()).get("access_token").toString();
            return token;
        }
    }
}
